<nav class="Page navigation example" xmlns:th="http://www.thymeleaf.org"  th:fragment="page_pager(number, offset, totalPages, url)" th:with="maxButtons=10,floatButtons=5">
        <ul class="pagination">
            <!-- 上一页 -->
            <li class="page-item" th:if="${number == 1}"><span class="page-link" >上一页</span></li>
            <li class="page-item" th:if="${number > 1}"><a class="page-link"  th:href="@{${url}(page=${number+offset-1})}">上一页</a></li>

            <!-- 首页 -->
            <li class="page-item active" th:if="${number == 1}" ><span class="page-link"  >1</span></li>
            <li class="page-item" th:if="${number > 1}"><a class="page-link"  th:href="@{${url}(page=${1+offset})}">1</a></li>

            <th:block th:if="${totalPages>2 && totalPages<=maxButtons}" th:each="i : ${#numbers.sequence(2,totalPages-1)}">
                <li class="page-item active" th:if="${number == i}" ><span class="page-link"  th:text="${i}">页码</span></li>
                <li class="page-item" th:if="${number != i}"><a class="page-link"  th:href="@{${url}(page=${i+offset})}" th:text="${i}">页码</a></li>
            </th:block>

            <th:block th:if="${totalPages > maxButtons}">
                <th:block th:if="${(number-(floatButtons/2)) <= 2}" th:each="i : ${#numbers.sequence(2,2+floatButtons-1)}">
                    <li class="page-item active" th:if="${number == i}" ><span class="page-link"  th:text="${i}">页码</span></li>
                    <li class="page-item " th:if="${number != i}"><a class="page-link"  th:href="@{${url}(page=${i+offset})}" th:text="${i}">页码</a></li>
                </th:block>
                <!-- ... -->
                <li class="page-item" th:if="${(number-(floatButtons/2))>2}"><span class="page-link"  >...</span></li>

                <th:block th:if="${((number-(floatButtons/2))>2) && ((number+(floatButtons/2)-(floatButtons%2==0?1:0)) < (totalPages-1))}"
                          th:each="i : ${#numbers.sequence(number-(floatButtons/2),number+(floatButtons/2)-(floatButtons%2==0?1:0))}">
                    <li class="page-item active " th:if="${number == i}" ><span class="page-link"  th:text="${i}">页码</span></li>
                    <li class="page-item" th:if="${number != i}"><a class="page-link"  th:href="@{${url}(page=${i+offset})}" th:text="${i}">页码</a></li>
                </th:block>

                <!-- ... -->
                <li class="page-item" th:if="${(number+(floatButtons/2)-(floatButtons%2==0?1:0)) < (totalPages-1)}"><span class="page-link" >...</span></li>
                <th:block th:if="${(number+(floatButtons/2)-(floatButtons%2==0?1:0)) >= (totalPages-1)}" th:each="i : ${#numbers.sequence(totalPages-floatButtons,totalPages-1)}">
                    <li class="page-item active" th:if="${number == i}" ><span class="page-link"  th:text="${i}">页码</span></li>
                    <li class="page-item" th:if="${number != i}"><a class="page-link"  th:href="@{${url}(page=${i+offset})}" th:text="${i}">页码</a></li>
                </th:block>
            </th:block>

            <!-- 最后一页 -->
            <li class="page-item active" th:if="${totalPages>1 && number == totalPages}" ><span class="page-link"  th:text="${totalPages}">页码</span></li>
            <li class="page-item" th:if="${totalPages>1 && number != totalPages}"><a class="page-link"  th:href="@{${url}(page=${totalPages+offset})}" th:text="${totalPages}">页码</a></li>

            <!-- 下一页 -->
            <li class="page-item" th:if="${number >= totalPages}"><span class="page-link"  >下一页</span></li>
            <li class="page-item" th:if="${number < totalPages}"><a class="page-link" th:href="@{${url}(page=${number+offset+1})}">下一页</a></li>
        </ul>
    </nav>